package me.cabbit.digitone.gui;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;

import me.cabbit.digitone.Application;

/**
 * The "About" Dialog. Present some boring info here
 * 
 * @author Arkaid
 */
public class AboutDialog extends JDialog implements WindowListener {
	private static final long serialVersionUID = -3157169319791187597L;

	/**
	 * Constructor. Build up all that boring text and show it
	 * 
	 * @param parent Parent window
	 */
	public AboutDialog (MainWindow parent)
	{
		super(parent);
		 
		//Title, size and lock resizing
		this.setTitle("About");
		this.setSize(320, 240);
		this.setResizable(false);	
		
		//make a panel and add all the labels
		JPanel panel = new JPanel();
		panel.setLayout(new GridBagLayout());
	
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbc.gridx = 0; gbc.gridy = GridBagConstraints.RELATIVE;
		
		//Text is here
		panel.add(new JLabel("Digitone version: " + Application.VERSION_STRING, JLabel.CENTER), gbc);
		panel.add(new JLabel("By Arkaid Deims", JLabel.CENTER), gbc);
		panel.add(new JLabel(" "), gbc);
		panel.add(new JLabel("Special thanks to Krechevskoy Faith", JLabel.CENTER), gbc);
		panel.add(new JLabel("for all the wonderful ideas", JLabel.CENTER), gbc);
		panel.add(new JLabel(" "), gbc);
		panel.add(new JLabel("Halftone Sample picture by Michael Coghlan", JLabel.CENTER), gbc);
		panel.add(new JLabel("http://www.flickr.com/photos/mikecogh", JLabel.CENTER), gbc);

				
		this.add(panel);

		this.setLocationRelativeTo(parent);
		
		this.addWindowListener(this);
	}

	//------------------------------------------------------------------//
	//------------------------- WindowListener -------------------------//
	//------------------------------------------------------------------//

	@Override
	public void windowActivated(WindowEvent e) {}

	@Override
	public void windowClosed(WindowEvent e) {}

	@Override
	public void windowClosing(WindowEvent e) 
	{
		this.dispose();
	}

	@Override
	public void windowDeactivated(WindowEvent e) {}

	@Override
	public void windowDeiconified(WindowEvent e) {}

	@Override
	public void windowIconified(WindowEvent e) {}

	@Override
	public void windowOpened(WindowEvent e) {}
}
